package com.cskaoyan.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * Handler方法的返回值为ModelAndView
 * @author stone
 * @date 2022/11/15 21:05
 */
@Controller
@RequestMapping("mv")
public class MvController {

    @RequestMapping("case1")
    public ModelAndView case1() {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("/hello.jsp");
        modelAndView.addObject("username", "松哥");
        return modelAndView;
    }
    @RequestMapping("case2")
    public String case2(Model model) {
        model.addAttribute("username", "李艮隶");
        return "/hello.jsp";
    }
}
